    //
    //  MainScreen.m
    //  ZooNgonDoiOS
    //
    //  Created by Trung sound on 7/24/12.
    //  Copyright (c) 2012 Personal. All rights reserved.
    //

#import "MainScreen.h"
#import "HomeScreen.h"
#import "IndividualScreen.h"

@implementation MainScreen
@synthesize parent = _parent;

#define VIEW_HEADER_HEIGHT 48
#define ITEM_HEADER_WIDTH 80

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        _btnHome = [[UIButton alloc]init];
        _btnTalk = [[UIButton alloc]init];
        _btnMe = [[UIButton alloc]init];
        _btnCheckin = [[UIButton alloc]init];
        
        _btnHome.frame = CGRectMake(0, 0, ITEM_HEADER_WIDTH, VIEW_HEADER_HEIGHT);
        _btnTalk.frame = CGRectMake(ITEM_HEADER_WIDTH, 0, ITEM_HEADER_WIDTH, VIEW_HEADER_HEIGHT);
        _btnMe.frame = CGRectMake(ITEM_HEADER_WIDTH*2, 0, ITEM_HEADER_WIDTH, VIEW_HEADER_HEIGHT);
        _btnCheckin.frame = CGRectMake(ITEM_HEADER_WIDTH*3, 0, ITEM_HEADER_WIDTH, VIEW_HEADER_HEIGHT);
        
        [_btnHome setBackgroundImage:[UIImage imageNamed:IMG_BTN_HOME_SELECTED] forState:UIControlStateNormal];
        
            //    [_btnHome setShowsTouchWhenHighlighted:YES];
        [_btnHome addTarget:self action:@selector(btnHomeClicked) forControlEvents:UIControlEventTouchUpInside];
        
        
        [_btnTalk setBackgroundImage:[UIImage imageNamed:IMG_BTN_TALK_NORMAL] forState:UIControlStateNormal];
        [_btnTalk addTarget:self action:@selector(btnTalk) forControlEvents:UIControlEventTouchUpInside];
        
        [_btnMe setBackgroundImage:[UIImage imageNamed:IMG_BTN_ME_NORMAL] forState:UIControlStateNormal];
        [_btnMe addTarget:self action:@selector(btnMeClicked) forControlEvents:UIControlEventTouchUpInside];
        
        [_btnCheckin setBackgroundImage:[UIImage imageNamed:IMG_BTN_CHECKIN_NORMAL] forState:UIControlStateNormal];
        [_btnCheckin addTarget:self action:@selector(btnCheckinClicked) forControlEvents:UIControlEventTouchUpInside];
        
        _mainView = [[UIView alloc]initWithFrame:CGRectMake(0, 48, 320, 412)];
        
        HomeScreen *homeScreen = [[HomeScreen alloc]initWithParent:CGRectMake(0, 0, 320, 412) parent:self];
        [_mainView addSubview:homeScreen];
        
        [self addSubview:_btnHome];
        [self addSubview:_btnTalk];
        [self addSubview:_btnMe];
        [self addSubview:_btnCheckin];
        [self addSubview:_mainView];
        
        [homeScreen release];
    }
    return self;
}

-(void)btnHomeClicked {
    [_btnHome setBackgroundImage:[UIImage imageNamed:IMG_BTN_HOME_SELECTED] forState:UIControlStateNormal];
    [_btnTalk setBackgroundImage:[UIImage imageNamed:IMG_BTN_TALK_NORMAL] forState:UIControlStateNormal];
    [_btnMe setBackgroundImage:[UIImage imageNamed:IMG_BTN_ME_NORMAL] forState:UIControlStateNormal];
    [_btnCheckin setBackgroundImage:[UIImage imageNamed:IMG_BTN_CHECKIN_NORMAL] forState:UIControlStateNormal];
    
    HomeScreen *homeScreen = [[HomeScreen alloc]initWithParent:CGRectMake(0, 0, 320, 412) parent:self];
    [_mainView addSubview:homeScreen];
    [homeScreen release];
}

-(void)btnTalk {
    [_btnHome setBackgroundImage:[UIImage imageNamed:IMG_BTN_HOME_NORMAL] forState:UIControlStateNormal];
    [_btnTalk setBackgroundImage:[UIImage imageNamed:IMG_BTN_TALK_SELECTED] forState:UIControlStateNormal];
    [_btnMe setBackgroundImage:[UIImage imageNamed:IMG_BTN_ME_NORMAL] forState:UIControlStateNormal];
    [_btnCheckin setBackgroundImage:[UIImage imageNamed:IMG_BTN_CHECKIN_NORMAL] forState:UIControlStateNormal];
}

-(void)btnMeClicked {
    [_btnHome setBackgroundImage:[UIImage imageNamed:IMG_BTN_HOME_NORMAL] forState:UIControlStateNormal];
    [_btnTalk setBackgroundImage:[UIImage imageNamed:IMG_BTN_TALK_NORMAL] forState:UIControlStateNormal];
    [_btnMe setBackgroundImage:[UIImage imageNamed:IMG_BTN_ME_SELECTED] forState:UIControlStateNormal];
    [_btnCheckin setBackgroundImage:[UIImage imageNamed:IMG_BTN_CHECKIN_NORMAL] forState:UIControlStateNormal];
    
    IndividualScreen *individualScreen = [[IndividualScreen alloc]initWithFrame:CGRectMake(0, 0, 320, 412)];
    [_mainView addSubview:individualScreen];
    [individualScreen release];
}

-(void)btnCheckinClicked {
    [_btnHome setBackgroundImage:[UIImage imageNamed:IMG_BTN_HOME_NORMAL] forState:UIControlStateNormal];
    [_btnTalk setBackgroundImage:[UIImage imageNamed:IMG_BTN_TALK_NORMAL] forState:UIControlStateNormal];
    [_btnMe setBackgroundImage:[UIImage imageNamed:IMG_BTN_ME_NORMAL] forState:UIControlStateNormal];
    [_btnCheckin setBackgroundImage:[UIImage imageNamed:IMG_BTN_CHECKIN_SELECTED] forState:UIControlStateNormal];
}

/**
 * Implement delegate
 * View spot detail when select a spot
 */
- (void)pushToSpotDetailScreen:(ZooSpotBean *)spot {
    HomeViewController *homeViewController = _parent;
    [homeViewController pushToDetailController:spot];
    
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect
 {
 // Drawing code
 }
 */

@end
